export const COMPREIFX = "yqd-";
export const INDENTIFICATION = {
  BASIC: "basic", //基础组件
  CUS_FORM: "cus-form", //自定义表单组件
  BUSINESS: "business", //业务组件
  OTHER: "other", // 其他组件 -> 模块组件
  ONLY: "only", // 唯一组件
  FORM_MODAL: "form-modal", //表单模块
  DESC_MODAL: "desc-modal", //装修模块
  PAGE_MODAL: "page-modal", //微页面
};

export const INDENTIFICATION_TEXT = {
  BASIC: "基础组件", //基础组件
  CUS_FORM: "自定义表单组件", //自定义表单组件
  BUSINESS: "业务组件", //业务组件
  OTHER: "其他组件", //其他组件
  ONLY: "唯一组件", //唯一组件
  FORM_MODAL: "表单模块", //表单模块
  DESC_MODAL: "装修模块", //装修模块
  PAGE_MODAL: "自定义表单", //微页面模块
};

export const NAVIGATE_PARAMS = {
  navigateType: "",
  path: "", // 内链地址
  url: "", // 外链地址
  serviceChatUrl: "", //企业客服
  serviceChatID: "", //企业ID
};

export const NAVIGATE_TYPE = {
  SELF: "self", //应用本身
  OUTSIDE: "outside", //外链
  SERVICE_CHAT: "serviceChat", //企业客服
};
/*
params:
        type: ''--无,'self'--应用本身，'outside'--外联
        target: ，目
*/
export const callNavigateHook = ({ type, target }) => {
  const NAVIGATE_TYPE = NAVIGATE_TYPE;
  switch (type) {
    case NAVIGATE_TYPE.SELF:
      uni.$u.route({
        url: target.path,
      });
      break;

    case NAVIGATE_TYPE.OUTSIDE:
      // #ifdef H5
      window.location.href = target.url;
      // #endif
      // #ifdef MP
      uni.$u.route({
        url: "pages/base/webview/index",
        params: {
          src: encodeURIComponent(target.url),
        },
      });
      // #endif
      break;

    case NAVIGATE_TYPE.SERVICE_CHAT:
      // #ifdef MP
      wx.openCustomerServiceChat({
        extInfo: {
          url: target.serviceChatUrl
        },
        corpId: target.serviceChatID,
        success() {},
        fail() {
          uni.showToast({
            title: '当前无客服', //提示文字
            icon: "none",
            duration: 2000, //显示时长
          })
        },
      })
      // #endif
      break;

    default:
      break;
  }
};
